home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / JunkMatcher 1.5.5.dmg / JunkMatcher.app / Contents / Resources / Engine / consts.py < prev    next >
Encoding:
Python Source  |  2005-06-01  |  2.4 KB  |  65 lines

  1. #
  2. #  consts.py
  3. #  JunkMatcher
  4. #
  5. #  Created by Benjamin Han on 2/1/05.
  6. #  Copyright (c) 2005 Benjamin Han. All rights reserved.
  7. #
  8.  
  9. # This program is free software; you can redistribute it and/or
  10. # modify it under the terms of the GNU General Public License
  11. # as published by the Free Software Foundation; either version 2
  12. # of the License, or (at your option) any later version.
  13.  
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. # GNU General Public License for more details.
  18.  
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22.  
  23. #!/usr/bin/env python
  24.  
  25. import sys, os, os.path, shutil, re
  26.  
  27. ROOT_PATH = '%s/' % os.path.split(os.path.split(os.path.abspath(__file__))[0])[0]
  28. DEFAULTS_PATH = '%s/Defaults/' % ROOT_PATH
  29. ENGINE_PATH = '%s/Engine/' % ROOT_PATH
  30. BIN_PATH = '%s/bin/' % ROOT_PATH
  31.  
  32. HOMELIB_PATH = os.path.expanduser('~/Library/')
  33. CONF_PATH = '%sApplication Support/JunkMatcher/' % HOMELIB_PATH
  34. TMP_PATH = '%stemp/' % CONF_PATH
  35.  
  36. # make sure we have the user-specific dirs and files
  37. if os.path.exists(CONF_PATH):
  38.     # check one by one if any file is missing
  39.     for f in os.listdir(DEFAULTS_PATH):
  40.         if not os.path.exists('%s%s' % (CONF_PATH, f)):
  41.             shutil.copy2('%s%s' % (DEFAULTS_PATH, f), '%s%s' % (CONF_PATH, f))
  42. else:
  43.     # copy the entire Defaults
  44.     shutil.copytree(DEFAULTS_PATH, CONF_PATH)
  45. if not os.path.exists(TMP_PATH): os.makedirs(TMP_PATH)
  46.  
  47. pythonSitePath = '%slib/python2.3/site-packages' % ROOT_PATH
  48. sys.path[0:0] = [ENGINE_PATH, pythonSitePath, '%s/PyObjC' % pythonSitePath, '%s/PyObjC/Foundation' % pythonSitePath]
  49.  
  50.  
  51. httpPat = re.compile(r'(?i)https?:/?/?[^"\'<> \t\n\r\f\v]+')      # allow "http:/site.com" and "http:site.com" too
  52. mpPat=re.compile(r'\(\?#[^)]+\)')                                 # pattern for names of meta patterns
  53.  
  54.  
  55. JM_ENGINE_VER = '1.5.5'
  56.  
  57. DEFAULT_FILE_ENCODING = 'utf8'      # encoding used to save files
  58. DEFAULT_MX_TIMEOUT = 10             # timeout value for finding MX records of domains
  59. SAFE_SITE_SIZE_RATIO=0.98           # keep this many sites out of sizeLimit (to minimize site database pruning operation)
  60.  
  61.  
  62. class JMExceptionMetaPattern (Exception):
  63.     def __init__ (self, info):
  64.         self.info = info
  65.